package org.csu.wuliu.service;

import org.csu.wuliu.domain.Item;
import org.csu.wuliu.domain.Warehouse;
import org.csu.wuliu.persistence.ItemMapper;
import org.csu.wuliu.persistence.WarehouseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class WarehouseService {

    @Autowired
    private WarehouseMapper warehouseMapper;

    @Autowired
    private ItemMapper itemMapper;

    //Warehouse相关
    public Warehouse getWarehouse(String WarehouseId){
        return warehouseMapper.getWarehouse(WarehouseId);
    }

    public boolean iswarehouseIdExist(String WarehouseId){
        if(getWarehouse(WarehouseId)==null){
            return false;
        }
        else return true;
    }

    public List<Warehouse> getWarehouseList(){
        return warehouseMapper.getWarehouseList();
    }

    public List<Item> getItemByWarehouseId(String warehouseId){return itemMapper.getItemListByWarehouseId(warehouseId);}

    public void insertWarehouse(Warehouse item){
        warehouseMapper.insertWarehouse(item);
    }

    public void deleteWarehouse(String warehouseId){
        warehouseMapper.deleteWarehouse(warehouseId);
    }

    public void updateWarehouse(Warehouse item){
        warehouseMapper.updateWarehouse(item);
    }
}
